package com.atguigu.lease.common.context;

public class LoginUserContext {
    //创建ThreadLocal用来保存数据到当前运行的线程中
    private static final ThreadLocal<LoginUser> userThreadLocal = new ThreadLocal<>();
    //保存到线程中
    public static void setLoginUser(LoginUser loginUser) {
        userThreadLocal.set(loginUser);
    }
    //获取信息
    public static LoginUser getLoginUser() {
        return userThreadLocal.get();
    }
    //清除信息
    public static void clear() {
        userThreadLocal.remove();
    }
}
